package cn.anlab.anappframe.demo.activity;

import java.util.List;
import java.util.Map;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
import android.widget.Spinner;
import android.widget.Toast;
import cn.anlab.anappframe.R;
import cn.anlab.anappframe.demo.DemoDataUtil;
import cn.anlab.anappframe.demo.adapter.HomeAdapter;
import cn.anlab.anappframe.widget.CompDialog;
import cn.anlab.anappframe.widget.CompProgressDialog;

public class WidgetDemoActivity extends Activity {
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.demo_widget);
		
		Dialog d = new Dialog(this);
		
		CompDialog dialog = new CompDialog(this);
		dialog.setTitle("Test Dialog");
		dialog.setMessage("How are  you? Marry.");
//		dialog.show();
		
		DialogInterface.OnClickListener dialogListener = new DialogInterface.OnClickListener() {
			@Override
			public void onClick(DialogInterface dialog, int which) {
				Toast.makeText(WidgetDemoActivity.this, "which = " + which, Toast.LENGTH_SHORT).show();
				dialog.dismiss();
			}
		};
		dialog.setButton(CompDialog.BUTTON1, "OK", dialogListener);
		dialog.setButton(CompDialog.BUTTON2, "Cancel", dialogListener);
		
		
//		CompProgressDialog pdialog = new CompProgressDialog(this);
//		pdialog.show();
		
		ImageView iv = (ImageView)findViewById(R.id.imageView1);
		Animation anim = AnimationUtils.loadAnimation(this, R.anim.rotate_loading);
		iv.startAnimation(anim);
	
		//下拉框
		List<Map<String, String>> itemList = DemoDataUtil.getHomeItem(15);
		HomeAdapter adapter = new HomeAdapter(this, itemList);
		Spinner spn = (Spinner)findViewById(R.id.spinner1);
		spn.setAdapter(adapter);
		itemList.remove(0);
		adapter.notifyDataSetChanged();
		
		
		new AlertDialog.Builder(this).setTitle("AlertDialog改样式").setMessage("改样式啦，终于成功了...").show();
		
		
		

	}

	
	
	
}

